package createModel.singletonMode.hungrySingleton;

public class ClientHungryTest {
    public static void main(String[] args) {
        // 饿汉式,单例模式, 线程安全, 效率低 , 占用额外的空间
        HungrySingleton instance = HungrySingleton.getInstance();

        // 线程安全,多次创建,都是同一对象
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                HungrySingleton instance1 = HungrySingleton.getInstance();
                System.out.println(instance1.hashCode());
            }).start();
        }
    }
}
